﻿using System;
using System.Collections.Generic;
using System.Text;
using LabMS.BLL;
using LabMS.Model;

namespace ExtendBLL
{
    public class Dictionary : LabMS.BLL.Dictionary
    {
        public List<LabMS.Model.Dictionary> GetItemListByDClass(string DClass)
        {
            string StrWhere = "";
            List<LabMS.Model.Dictionary> listCClass = new List<LabMS.Model.Dictionary>();
            LabMS.BLL.Dictionary bDictionary = new LabMS.BLL.Dictionary();

            if (!DClass.Equals(string.Empty))
            {
                StrWhere = "DClass = '" + DClass + "' ";
            }
            else
            {
                return null;
            }
            try
            {
                listCClass = bDictionary.GetModelList(StrWhere);
            }
            catch(Exception ex)
            {
                throw(new Exception("数据库链接错误"));
            }
            return listCClass;
        }

        /// <summary>
        /// 根据DClass找到对应的表头
        /// </summary>
        /// <param name="DClass"></param>
        /// <returns></returns>
        public string[] GetHeaderByDClass(string DClass)
        {
            string[] hearer=new string[2];
            switch (DClass)
            {
                case "201":
                    hearer[0]="性别码";
                    hearer[1]="性别名称";
                    break;
                case "dangwei":
                    hearer[0] = "单位编码";
                    hearer[1] = "单位名称";
                    break;
                case "haocaileibie":
                    hearer[0] = "耗材类别编码";
                    hearer[1] = "耗材类别名称";
                    break;
                case "shebeilaiyuan":
                    hearer[0] = "设备来源编码";
                    hearer[1] = "设备来源名称";
                    break;
                case "shiyongfangxiang":
                    hearer[0] = "使用方向编码";
                    hearer[1] = "使用方向名称";
                    break;
                case "shebeizhuangtai":
                    hearer[0] = "设备状态编码";
                    hearer[1] = "设备状态名称";
                    break;
                case "jingfeikemu":
                    hearer[0] = "经费科目编码";
                    hearer[1] = "经费科目名称";
                    break;
                case "guobie":
                    hearer[0] = "国别编码";
                    hearer[1] = "国别名称";
                    break;
                case "lowvalue":
                    hearer[0] = "低值品编码";
                    hearer[1] = "低值品名称";
                    break;
                case "estatus":
                    hearer[0] = "仪器状态编码";
                    hearer[1] = "仪器状态名称";
                    break;
                case "111":
                    hearer[0] = "实验室类别编码";
                    hearer[1] = "实验室类别名称";
                    break;
                case "112":
                    hearer[0] = "实验室类型编码";
                    hearer[1] = "实验室类型名称";
                    break;
                case "113":
                    hearer[0] = "实验室级别编码";
                    hearer[1] = "实验室级别名称";
                    break;
                case "114":
                    hearer[0] = "实验室奖励级别编码";
                    hearer[1] = "实验室奖励级别名称";
                    break;
                case "115":
                    hearer[0] = "实验室使用状态编码";
                    hearer[1] = "实验室使用状态名称";
                    break;
                case "116":
                    hearer[0] = "实验室获奖类型编码";
                    hearer[1] = "实验室获奖类型名称";
                    break;
                case "117":
                    hearer[0] = "房间使用状态编码";
                    hearer[1] = "房间使用状态名称";
                    break;
                case "118":
                    hearer[0] = "规章制度类型编码";
                    hearer[1] = "规章制度类型名称";
                    break;
                case "119":
                    hearer[0] = "评估标准类别编码";
                    hearer[1] = "评估标准类别名称";
                    break;
                case "xueke":
                    hearer[0] = "学科编码";
                    hearer[1] = "学科名称";
                    break;
                case "shiyanleibie":
                    hearer[0] = "实验类别编码";
                    hearer[1] = "实验类别名称";
                    break;
                case "shiyanleixing":
                    hearer[0] = "实验类型编码";
                    hearer[1] = "实验类型名称";
                    break;
                case "shiyanyaoqiu":
                    hearer[0] = "实验要求编码";
                    hearer[1] = "实验要求名称";
                    break;
                case "shiyanzheleibie":
                    hearer[0] = "实验者类别编码";
                    hearer[1] = "实验者类别名称";
                    break;
                case "shiyanxiangmulaiyuan":
                    hearer[0] = "实验项目来源编码";
                    hearer[1] = "实验项目来源名称";
                    break;
                case "App_LabType":
                    hearer[0] = "实验室类别编码";
                    hearer[1] = "实验室类别名称";
                    break;
                case "App_ConstructionType":
                    hearer[0] = "建设类别编码";
                    hearer[1] = "建设类别名称";
                    break;
                case "App_State":
                    hearer[0] = "实验室状态编码";
                    hearer[1] = "实验室状态名称";
                    break;
                case "App_Position":
                    hearer[0] = "职务编码";
                    hearer[1] = "职务名称";
                    break;
                case "TeachingReform":
                    hearer[0] = "教改项目类别编码";
                    hearer[1] = "教改项目类别名称";
                    break;
                case "UnitType":
                    hearer[0] = "单位类别编码";
                    hearer[1] = "单位类别名称";
                    break;
                case "Project_Category":
                    hearer[0] = "实验室项目类别编码";
                    hearer[1] = "实验室项目类别名称";
                    break;
                case "Project_AwardLevel":
                    hearer[0] = "实验室奖励级别编码";
                    hearer[1] = "实验室奖励级别名称";
                    break;
                case "Project_PartnerType":
                    hearer[0] = "实验者类别编码";
                    hearer[1] = "实验者类别名称";
                    break;
                case "Project_Type":
                    hearer[0] = "实验类型编码";
                    hearer[1] = "实验类型名称";
                    break;
                case "Project_Request":
                    hearer[0] = "实验要求编码";
                    hearer[1] = "实验要求名称";
                    break;
                case "Project_Change":
                    hearer[0] = "变动情况编码";
                    hearer[1] = "变动情况名称";
                    break;
                case "Project_CourseMode":
                    hearer[0] = "授课模式编码";
                    hearer[1] = "授课模式名称";
                    break;
                case "Subject":
                    hearer[0] = "学科编码";
                    hearer[1] = "学科名称";
                    break;
                case "Position":
                    hearer[0] = "职位/职务编码";
                    hearer[1] = "职位/职务名称";
                    break;
                case "CourseType":
                    hearer[0] = "课程属性编码";
                    hearer[1] = "课程属性名称";
                    break;
                case "Conflict":
                    hearer[0] = "是否检查冲突编码";
                    hearer[1] = "是否检查冲突名称";
                    break;
                case "perprojectstatus":
                    hearer[0] = "自拟实验项目状态编码";
                    hearer[1] = "自拟实验项目状态名称";
                    break;
                case "ruxuenianfen":
                    hearer[0] = "入学年份编码";
                    hearer[1] = "入学年份名称";
                    break;
                case "guizhongyiqi":
                    hearer[0] = "贵重仪器编码";
                    hearer[1] = "贵重仪器名称";
                    break;
                case "yiqi":
                    hearer[0] = "仪器编码";
                    hearer[1] = "仪器名称";
                    break;
                case "education":
                    hearer[0] = "文化程度编码";
                    hearer[1] = "文化程度名称";
                    break;
                case "paperlevel":
                    hearer[0] = "论文级别编码";
                    hearer[1] = "论文级别名称";
                    break;
                case "publicationslevel":
                    hearer[0] = "著作级别编码";
                    hearer[1] = "著作级别名称";
                    break;
                case "employ":
                    hearer[0] = "任聘情况编码";
                    hearer[1] = "任聘情况名称";
                    break;
                case "work":
                    hearer[0] = "主要工作编码";
                    hearer[1] = "主要工作名称";
                    break;
                case "parttimetype":
                    hearer[0] = "人员类别编码";
                    hearer[1] = "人员类别名称";
                    break;
                case "stafflevel":
                    hearer[0] = "人员类别等级编码";
                    hearer[1] = "人员类别等级名称";
                    break;
                case "expertlevel":
                    hearer[0] = "专家类别编码";
                    hearer[1] = "专家类别名称";
                    break;
            }
            return hearer;
        }

        /// <summary>
        /// 在新增项时检查Code是否存在
        /// </summary>
        /// <param name="DClass"></param>
        /// <param name="Code"></param>
        /// <returns></returns>
        public int IsCodeExist(string DClass, string Code)
        {
            string str = "DClass='" + DClass + "' and Code='"+Code+"'";
            LabMS.BLL.Dictionary BD = new LabMS.BLL.Dictionary();
            List<LabMS.Model.Dictionary> list = new List<LabMS.Model.Dictionary>();
            list=BD.GetModelList(str);
            if (list.Count > 0)
            {
                //已经存在
                return 0;
            }
            else
            {
                //不存在
                return 1;
            }
        }

        /// <summary>
        /// 根据ID获得字典表中其它项的内容
        /// </summary>
        public List<LabMS.Model.Dictionary> GetListByID(long ID)
        {
            string str = "ID="+ID;
            LabMS.BLL.Dictionary BD = new LabMS.BLL.Dictionary();
            List<LabMS.Model.Dictionary> list = new List<LabMS.Model.Dictionary>();
            list=BD.GetModelList(str);
            return list;
        }

        /// <summary>
        /// 根据DClass从字典大类中查出Name的值
        /// </summary>
        /// <param name="DClass"></param>
        /// <returns></returns>
        public string GetNameFromDictionaryClass(string DClass)
        {
            LabMS.BLL.DictionaryClass bDictionaryClass = new LabMS.BLL.DictionaryClass();
            string str = "Code='"+DClass+"'";
            return bDictionaryClass.GetModelList(str)[0].Name;
        }
    }
}
